package com.eascs.admin.o2o.internal.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.eascs.admin.common.dao.BaseO2oDao;
import com.eascs.admin.o2o.internal.entity.WfTypeStatus;
import com.eascs.admin.o2o.internal.util.StatusContexts;
import com.eascs.app.dao.PageResult;
import com.eascs.app.dao.SqlPageQuery;

/**
 * 
 * 主流程----状态表
 *
 */
@Repository
public class WfTypeStatusDao extends BaseO2oDao{
	/**
	 * 根据主表ID和WfType  查询WfTypeStatus实体
	 * @param loanapplyNo
	 * @param wfType
	 * @return
	 */
	public WfTypeStatus getByLoanapplyNoAndWfType(String loanapplyNo, String wfType) {
		String sql = "select * from wf_type_status where loanapply_no = ? and wf_type = ?";
		WfTypeStatus wfTypeStatus = o2oJdbcSession.findEntity(sql, WfTypeStatus.class, loanapplyNo, wfType);
		return wfTypeStatus;
	}
	/**
	 * 根据主表ID查询 List<WfTypeStatus>
	 * @param loanapplyNo
	 * @return
	 */
	public List<WfTypeStatus> queryWfTypeStatus(String loanapplyNo){
		String sql="select * from wf_type_status od where od.loanapply_no=? and od.wf_status!=?";
		return this.findEntitys(sql, WfTypeStatus.class, loanapplyNo,StatusContexts.WFTYPE_STATUS_NEW);
	}
	/**
	 * WfTypeStatus 列表
	 * @param wts
	 * @param pageSize
	 * @param pageIndex
	 * @return
	 */
	public PageResult<WfTypeStatus> queryListPage(WfTypeStatus wts, int pageSize, int pageIndex){
		StringBuffer sb=new StringBuffer("select * from o2o_auditcomments od where 1=1 ");
		SqlPageQuery<WfTypeStatus> sqlPageQuery=new SqlPageQuery<WfTypeStatus>(WfTypeStatus.class, pageSize, pageIndex,sb.toString());
		return this.findDataWithPage(sqlPageQuery);
	}
}
